const Mock = require('mockjs')

const List = []
const count = 100

for(let i = 0;i < count;i++) {
  List.push(Mock.mock({
    id: '@increment', // id
    name: '@first', // 角色名称
    title: '@title(5, 10)', // 角色说明
    'status|1': ['1', '2'], //是否设置权限
  }))
}
module.exports = [
  {
    url: '/TongMSK/userArticle/list',
    type: 'get',
    response: config => {
      const { title, page = 1, limit = 20 } = config.query
      let mockList = List.filter(item => {
        if (title && item.name.indexOf(title) < 0) return false // 筛选出不符合条件的数据
        return true
      })
      const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
      // const pageList = List.filter((item, index) => index < limit * page && index >= limit * (page - 1))
      return {
        code: 20000,
        data: {
          total: mockList.length,
          items: pageList
        }
      }
    }
  },
  {
    url: '/TongMSK/userArticle/add',
    type: 'post',
    response: _ => {
      return {
        code: 20000,
        data: 'success'
      }
    }
  },
  {
    url: '/TongMSK/userArticle/edit',
    type: 'post',
    response: _ => {
      return {
        code: 20000,
        data: 'success'
      }
    }
  }
]